05. Bayes' Rule

Before we dive into deeper into Markov localization, we should review Bayes' Rule. This will serve as a refresher for those familiar with Bayesian methods and we provide some additional resources for those less familiar.

Recall that Bayes' Rule enables us to determine the conditional probability of a state given evidence P(a|b) by relating it to the conditional probability of the evidence given the state P(b|a) in the form of:

P(a)*P(b|a) = P(b)*P(a|b)

which can be rearranged to:

P(a|b) = \frac{P(b|a) \, P(a)}{P(b)}

In other words the probability of state a, given evidence b, is the probability of evidence b, given state a, multiplied by the probability of state a, normalized by the total probability of b over all states.

Let's move on to an example to illustrate the utility of Bayes' Rule.

Bayes' Rule Applied

Let's say we have two bags of marbles, bag 1 and bag 2, filled with two types of marbles, red and blue. Bag 1 contains 10 blue marbles and 30 red marbles, whereas bag 2 contains 20 of each color marble.

If a friend were to choose a bag at random and then a marble at random, from that bag, how can we determine the probability that that marble came from a specific bag? You guessed it - Bayes' Rule!

In this scenario, our friend produces a red marble, in that case, what is the probability that the marble came from bag 1? Rewriting this in terms of Bayes' Rule, our solution becomes:

P(Bag1 | Red) = \frac{P(Red | Bag1) \, P(Bag1)}{P(Red)}

Let's walk through the process in the following quizzes.

Calculate Prior

What is the prior probability of choosing bag 1? This is the term P(Bag1) .

SOLUTION: 0.50

Calculate Likelihood

What is the probability of choosing a red marble from bag 1? This is our likelihood term P(Red|Bag1) .

SOLUTION: 0.75

What is the total probability of choosing a red marble? This is our normalization term (denominator) P(Red) .

SOLUTION: 0.625

Now, putting everything together, using the formula for Bayes' Rule, what is our posterior probability of the red marble originating from bag 1? This is our posterior term P(Bag1|Red) ?

SOLUTION: 0.60